package controller;

import java.io.IOException;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import dao.SuSheDao;

/**
 * Servlet implementation class U_Wy_SuSheServlet
 */
@WebServlet("/U_Wy_SuSheServlet")
public class U_Wy_SuSheServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public U_Wy_SuSheServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		// TODO Auto-generated method stub
				boolean b = false; // 初始化返回值为 false
				String number = request.getParameter("roomid");
				String status = request.getParameter("quota");
				String refuse = request.getParameter("guige");
				
				// 设置响应内容类型
		        response.setContentType("text/html;charset=UTF-8");
				SuSheDao dao = new SuSheDao();
					
				
				//将数据写入数据库
				b=dao.WyUpdateleave(number,status, refuse);
						
				//修改成功，弹出成功提示框
				if(b==true) {						
					// 跳转回原页面
					response.sendRedirect("View_SuShe/SuSheWyMain.jsp");
			        
				}else {
					System.out.print("请假清单修改失败 ");
				}
	}

}
